<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Projet Jetpack:  Fichier source de /home/p1006250/lif7-projet-jetpack/src/SdlJeu.c</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Projet Jetpack
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Généré par Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Page&#160;principale</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Fichiers</span></a></li>
      <li><a href="dirs.html"><span>Répertoires</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Liste&#160;des&#160;fichiers</span></a></li>
      <li><a href="globals.html"><span>Membres&#160;de&#160;fichier</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_sdl_jeu_8c.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">SdlJeu.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_sdl_jeu_8c.html">Aller à la documentation de ce fichier.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &quot;<a class="code" href="_sdl_jeu_8h.html">SdlJeu.h</a>&quot;</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 
<a name="l00004"></a><a class="code" href="_sdl_jeu_8h.html#a92ebd83590fab5f62f26f371b60e1b14">00004</a> <span class="keywordtype">void</span> <a class="code" href="_sdl_jeu_8c.html#a92ebd83590fab5f62f26f371b60e1b14" title=" Brief Description  Initialise les tilesets.   ">tilesetInit</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> * level, <a class="code" href="structs_terrain.html">Terrain</a> * pTer, <a class="code" href="struct_tileset_struct.html">TilesetStruct</a> * pTile)
<a name="l00005"></a>00005 {
<a name="l00006"></a>00006     FILE* F;
<a name="l00007"></a>00007     <span class="keywordtype">char</span> buf[<a class="code" href="_sdl_jeu_8h.html#a8a6befd630ea1c2ab260266f7466540c">CACHE_SIZE</a>];
<a name="l00008"></a>00008         F = fopen(level,<span class="stringliteral">&quot;r&quot;</span>); <span class="comment">// ouvre le niveau choisit avec const char level</span>
<a name="l00009"></a>00009         <span class="keywordflow">if</span> (!F)
<a name="l00010"></a>00010                 printf(<span class="stringliteral">&quot;fichier level introuvable\n&quot;</span>);<span class="comment">// le niveau n&#39;existe pas</span>
<a name="l00011"></a>00011         fgets(buf,<a class="code" href="_sdl_jeu_8h.html#a8a6befd630ea1c2ab260266f7466540c">CACHE_SIZE</a>,F);
<a name="l00012"></a>00012 
<a name="l00013"></a>00013         <span class="keywordflow">do</span>
<a name="l00014"></a>00014         {
<a name="l00015"></a>00015                 fscanf(F,<span class="stringliteral">&quot;%s&quot;</span>,buf);
<a name="l00016"></a>00016                 <span class="keywordflow">if</span> (strstr(buf,<span class="stringliteral">&quot;#tileset&quot;</span>))
<a name="l00017"></a>00017                         <a class="code" href="_sdl_jeu_8c.html#af207f90fc1d6368579d6f71377c41843" title=" Brief Description  Charge les tileset.  ">chargerTilesetSDL</a>(F,pTer,pTile);
<a name="l00018"></a>00018         } <span class="keywordflow">while</span> (strstr(buf,<span class="stringliteral">&quot;#fin&quot;</span>)==NULL);
<a name="l00019"></a>00019         fclose(F);
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 }
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 
<a name="l00024"></a><a class="code" href="_sdl_jeu_8h.html#a152cc45e4b709a2ea3858f7e6f12cdce">00024</a> SDL_Surface* <a class="code" href="_sdl_jeu_8c.html#a152cc45e4b709a2ea3858f7e6f12cdce" title=" Brief Description  Charge une image.  ">LoadImage32</a>(SDL_Surface* tileset, <span class="keyword">const</span> <span class="keywordtype">char</span>* fichier_image)
<a name="l00025"></a>00025 {
<a name="l00026"></a>00026         tileset = SDL_LoadBMP(fichier_image);   <span class="comment">// charge l&#39;image dans image_ram en RAM</span>
<a name="l00027"></a>00027         <span class="keywordflow">if</span> (tileset==NULL)
<a name="l00028"></a>00028         {
<a name="l00029"></a>00029                 printf(<span class="stringliteral">&quot;Image %s introuvable !! \n&quot;</span>,fichier_image);
<a name="l00030"></a>00030                 SDL_Quit();
<a name="l00031"></a>00031                 system(<span class="stringliteral">&quot;pause&quot;</span>);
<a name="l00032"></a>00032                 exit(-1);
<a name="l00033"></a>00033         }
<a name="l00034"></a>00034     <span class="keywordflow">return</span> tileset;
<a name="l00035"></a>00035 }
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 
<a name="l00038"></a><a class="code" href="_sdl_jeu_8h.html#a31fa5a48dea220386eb12a751b881e62">00038</a> <span class="keywordtype">int</span> <a class="code" href="_sdl_jeu_8c.html#ace46279dca20b51cfe4dc815c0bf28f4" title=" Brief Description  Affiche un sprite.  ">AfficherSprite</a>(<a class="code" href="struct_sprite.html">Sprite</a>* pSprite,SDL_Surface* screen)
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040 
<a name="l00041"></a>00041         SDL_Surface * mario = NULL;
<a name="l00042"></a>00042         SDL_Rect R;
<a name="l00043"></a>00043         mario=<a class="code" href="_sdl_jeu_8c.html#a152cc45e4b709a2ea3858f7e6f12cdce" title=" Brief Description  Charge une image.  ">LoadImage32</a>(mario,<span class="stringliteral">&quot;data/mario.bmp&quot;</span>);
<a name="l00044"></a>00044         R.x = pSprite-&gt;pPer-&gt;posX - pSprite-&gt;pTer-&gt;xscroll;
<a name="l00045"></a>00045         R.y = pSprite-&gt;pPer-&gt;posY;
<a name="l00046"></a>00046         R.w = pSprite-&gt;pPer-&gt;w;
<a name="l00047"></a>00047         R.h = pSprite-&gt;pPer-&gt;h;
<a name="l00048"></a>00048         SDL_BlitSurface(mario,NULL,screen,&amp;R);
<a name="l00049"></a>00049 
<a name="l00050"></a>00050         <span class="keywordflow">return</span> 0;
<a name="l00051"></a>00051 }
<a name="l00052"></a>00052 
<a name="l00053"></a>00053 
<a name="l00054"></a><a class="code" href="_sdl_jeu_8h.html#a79155188b3432437d7b7e8853074a60e">00054</a> <span class="keywordtype">int</span> <a class="code" href="_sdl_jeu_8c.html#a79155188b3432437d7b7e8853074a60e" title=" Brief Description  Affiche la carte.   ">AfficherMapSDL</a>(<a class="code" href="structs_terrain.html">Terrain</a>* pTer,SDL_Surface* screen, <a class="code" href="struct_sprite.html">Sprite</a> * pSprite, <a class="code" href="struct_tileset_struct.html">TilesetStruct</a> * pTile)
<a name="l00055"></a>00055 {
<a name="l00056"></a>00056         <span class="keywordtype">int</span> i,j;
<a name="l00057"></a>00057         SDL_Rect Rect_dest;
<a name="l00058"></a>00058         <span class="keywordtype">int</span> numero_tile;
<a name="l00059"></a>00059         <span class="keywordtype">int</span> minx,maxx,miny,maxy;
<a name="l00060"></a>00060         <a class="code" href="_sprite_8c.html#affba9d86f8ae9fe08348877045147d9f" title=" Brief Description  Met à jour le scrolling.  ">UpdateScroll</a>(pTer, pSprite);
<a name="l00061"></a>00061         minx = pTer-&gt;<a class="code" href="structs_terrain.html#a5692b40e1e9677764b6da00a4c2c24e9">xscroll</a> / pTer-&gt;<a class="code" href="structs_terrain.html#ab958ea78e1078769b3e02c1618b5c015">LARGEUR_TILE</a>-1;
<a name="l00062"></a>00062         miny = -1;
<a name="l00063"></a>00063         maxx = (pTer-&gt;<a class="code" href="structs_terrain.html#a5692b40e1e9677764b6da00a4c2c24e9">xscroll</a> + pTer-&gt;<a class="code" href="structs_terrain.html#a0e051c9ed4fa978482d6b31da8bf1ec1">largeur_fenetre</a>)/pTer-&gt;<a class="code" href="structs_terrain.html#ab958ea78e1078769b3e02c1618b5c015">LARGEUR_TILE</a>;
<a name="l00064"></a>00064         maxy = pTer-&gt;<a class="code" href="structs_terrain.html#add43770da89e527d94605cea90ca3491">hauteur_fenetre</a>/pTer-&gt;<a class="code" href="structs_terrain.html#add63ba136dabd9690e18e14258093f16">HAUTEUR_TILE</a>;<span class="comment">// prend les dimensions de la fenetre</span>
<a name="l00065"></a>00065 
<a name="l00066"></a>00066         <span class="keywordflow">for</span>(i=minx;i&lt;=maxx;i++)
<a name="l00067"></a>00067         {
<a name="l00068"></a>00068                 <span class="keywordflow">for</span>(j=miny;j&lt;=maxy;j++)
<a name="l00069"></a>00069                 {
<a name="l00070"></a>00070                         Rect_dest.x = (i*pTer-&gt;<a class="code" href="structs_terrain.html#ab958ea78e1078769b3e02c1618b5c015">LARGEUR_TILE</a> - pTer-&gt;<a class="code" href="structs_terrain.html#a5692b40e1e9677764b6da00a4c2c24e9">xscroll</a>);
<a name="l00071"></a>00071                         Rect_dest.y = (j*pTer-&gt;<a class="code" href="structs_terrain.html#add63ba136dabd9690e18e14258093f16">HAUTEUR_TILE</a>);
<a name="l00072"></a>00072                         <span class="keywordflow">if</span> (i&lt;0 || j&lt;0 || j&gt;=pTer-&gt;<a class="code" href="structs_terrain.html#ab27a7bca0b8d1bfd8c501b0b8b4c6e69">nbtiles_hauteur_monde</a>)
<a name="l00073"></a>00073                                 numero_tile = 0;
<a name="l00074"></a>00074                         <span class="keywordflow">else</span>
<a name="l00075"></a>00075                                 numero_tile = pTer-&gt;<a class="code" href="structs_terrain.html#a8ee104dd02c94a9fdbba663441b4d2da">schema</a>[i%pTer-&gt;<a class="code" href="structs_terrain.html#af4ffcf044ec7b408dbad1fbb981de1c9">nbtiles_largeur_monde</a>][j];
<a name="l00076"></a>00076                         SDL_BlitSurface(pTile-&gt;<a class="code" href="struct_tileset_struct.html#a074228423034ef5970eb0063e47f17d9">tileset</a>,&amp;(pTile-&gt;<a class="code" href="struct_tileset_struct.html#a9ae987ca523efb4efdffd1153dae13ee">props</a>[numero_tile]),screen,&amp;Rect_dest);
<a name="l00077"></a>00077                 }
<a name="l00078"></a>00078         }
<a name="l00079"></a>00079         <span class="keywordflow">return</span> 0;
<a name="l00080"></a>00080 }
<a name="l00081"></a>00081 
<a name="l00082"></a><a class="code" href="_sdl_jeu_8h.html#af207f90fc1d6368579d6f71377c41843">00082</a> <span class="keywordtype">void</span> <a class="code" href="_sdl_jeu_8c.html#af207f90fc1d6368579d6f71377c41843" title=" Brief Description  Charge les tileset.  ">chargerTilesetSDL</a>(FILE* F,<a class="code" href="structs_terrain.html">Terrain</a>* pTer, <a class="code" href="struct_tileset_struct.html">TilesetStruct</a> * pTile)
<a name="l00083"></a>00083 {
<a name="l00084"></a>00084         <span class="keywordtype">int</span> numtile,i,j;
<a name="l00085"></a>00085         <span class="keywordtype">char</span> buf[<a class="code" href="_sdl_jeu_8h.html#a8a6befd630ea1c2ab260266f7466540c">CACHE_SIZE</a>];  <span class="comment">// un buffer, petite mémoire cache</span>
<a name="l00086"></a>00086         <span class="keywordtype">char</span> buf2[<a class="code" href="_sdl_jeu_8h.html#a8a6befd630ea1c2ab260266f7466540c">CACHE_SIZE</a>];  <span class="comment">// un buffer, petite mémoire cache</span>
<a name="l00087"></a>00087         fscanf(F,<span class="stringliteral">&quot;%s&quot;</span>,buf); <span class="comment">// nom du fichier</span>
<a name="l00088"></a>00088     pTile-&gt;<a class="code" href="struct_tileset_struct.html#a074228423034ef5970eb0063e47f17d9">tileset</a>=<a class="code" href="_sdl_jeu_8c.html#a152cc45e4b709a2ea3858f7e6f12cdce" title=" Brief Description  Charge une image.  ">LoadImage32</a>(pTile-&gt;<a class="code" href="struct_tileset_struct.html#a074228423034ef5970eb0063e47f17d9">tileset</a>, buf);<span class="comment">// charge le buffer dans le tileset</span>
<a name="l00089"></a>00089         fscanf(F,<span class="stringliteral">&quot;%d %d&quot;</span>,&amp;pTer-&gt;<a class="code" href="structs_terrain.html#ae492d90d2e194e0a52854cf384d98cbf">nbtilesX</a>,&amp;pTer-&gt;<a class="code" href="structs_terrain.html#ae1aadb12d851b94edc5e17bd040ff221">nbtilesY</a>);<span class="comment">// charge le nombre de tiles en largeur et longueur</span>
<a name="l00090"></a>00090         pTer-&gt;<a class="code" href="structs_terrain.html#ab958ea78e1078769b3e02c1618b5c015">LARGEUR_TILE</a> = pTile-&gt;<a class="code" href="struct_tileset_struct.html#a074228423034ef5970eb0063e47f17d9">tileset</a>-&gt;w/pTer-&gt;<a class="code" href="structs_terrain.html#ae492d90d2e194e0a52854cf384d98cbf">nbtilesX</a>;<span class="comment">// charge la largeur d&#39;un seul tile ( taille / nbtile)</span>
<a name="l00091"></a>00091         pTer-&gt;<a class="code" href="structs_terrain.html#add63ba136dabd9690e18e14258093f16">HAUTEUR_TILE</a> = pTile-&gt;<a class="code" href="struct_tileset_struct.html#a074228423034ef5970eb0063e47f17d9">tileset</a>-&gt;h/pTer-&gt;<a class="code" href="structs_terrain.html#ae1aadb12d851b94edc5e17bd040ff221">nbtilesY</a>;<span class="comment">// charge la hauteur d&#39;un seul tile (taille / nbtile)</span>
<a name="l00092"></a>00092         pTile-&gt;<a class="code" href="struct_tileset_struct.html#a9ae987ca523efb4efdffd1153dae13ee">props</a> = malloc(pTer-&gt;<a class="code" href="structs_terrain.html#ae492d90d2e194e0a52854cf384d98cbf">nbtilesX</a>*pTer-&gt;<a class="code" href="structs_terrain.html#ae1aadb12d851b94edc5e17bd040ff221">nbtilesY</a>*<span class="keyword">sizeof</span>(SDL_Rect));<span class="comment">//alloue la mémoire pour chaque tile et rentre s il est plein</span>
<a name="l00093"></a>00093         <span class="keywordflow">for</span>(j=0,numtile=0;j&lt;pTer-&gt;<a class="code" href="structs_terrain.html#ae1aadb12d851b94edc5e17bd040ff221">nbtilesY</a>;j++)
<a name="l00094"></a>00094         {
<a name="l00095"></a>00095                 <span class="keywordflow">for</span>(i=0;i&lt;pTer-&gt;<a class="code" href="structs_terrain.html#ae492d90d2e194e0a52854cf384d98cbf">nbtilesX</a>;i++,numtile++)
<a name="l00096"></a>00096                 {
<a name="l00097"></a>00097                         pTile-&gt;<a class="code" href="struct_tileset_struct.html#a9ae987ca523efb4efdffd1153dae13ee">props</a>[numtile].w = pTer-&gt;<a class="code" href="structs_terrain.html#ab958ea78e1078769b3e02c1618b5c015">LARGEUR_TILE</a>;
<a name="l00098"></a>00098                         pTile-&gt;<a class="code" href="struct_tileset_struct.html#a9ae987ca523efb4efdffd1153dae13ee">props</a>[numtile].h = pTer-&gt;<a class="code" href="structs_terrain.html#add63ba136dabd9690e18e14258093f16">HAUTEUR_TILE</a>;
<a name="l00099"></a>00099                         pTile-&gt;<a class="code" href="struct_tileset_struct.html#a9ae987ca523efb4efdffd1153dae13ee">props</a>[numtile].x = i*pTer-&gt;<a class="code" href="structs_terrain.html#ab958ea78e1078769b3e02c1618b5c015">LARGEUR_TILE</a>;
<a name="l00100"></a>00100                         pTile-&gt;<a class="code" href="struct_tileset_struct.html#a9ae987ca523efb4efdffd1153dae13ee">props</a>[numtile].y = j*pTer-&gt;<a class="code" href="structs_terrain.html#add63ba136dabd9690e18e14258093f16">HAUTEUR_TILE</a>;
<a name="l00101"></a>00101                         fscanf(F,<span class="stringliteral">&quot;%s %s&quot;</span>,buf,buf2);
<a name="l00102"></a>00102                         pTer-&gt;<a class="code" href="structs_terrain.html#afd885af4967004f679bcfbe9bcf7e14f">tileplein</a>[numtile]= 0;
<a name="l00103"></a>00103                         <span class="keywordflow">if</span> (strcmp(buf2,<span class="stringliteral">&quot;plein&quot;</span>)==0)
<a name="l00104"></a>00104                                 pTer-&gt;<a class="code" href="structs_terrain.html#afd885af4967004f679bcfbe9bcf7e14f">tileplein</a>[numtile] = 1;<span class="comment">// pour chaques tiles check si c&#39;est plein</span>
<a name="l00105"></a>00105                 }
<a name="l00106"></a>00106         }
<a name="l00107"></a>00107 }
<a name="l00108"></a>00108 
<a name="l00109"></a>00109 
<a name="l00110"></a>00110 
<a name="l00111"></a><a class="code" href="_sdl_jeu_8h.html#a907831170dedec3a0af4e4b1e178b854">00111</a> <span class="keywordtype">void</span> <a class="code" href="_sdl_jeu_8c.html#a907831170dedec3a0af4e4b1e178b854" title=" Brief Description  Analyse l&#39;état des events.  ">updateEvents</a>(<a class="code" href="struct_input.html">Input</a>* in)
<a name="l00112"></a>00112 {
<a name="l00113"></a>00113         SDL_Event event;
<a name="l00114"></a>00114         <span class="keywordflow">while</span>(SDL_PollEvent(&amp;event)) <span class="comment">//SDL_PollEvent teste si event != NULL</span>
<a name="l00115"></a>00115         {
<a name="l00116"></a>00116                 <span class="keywordflow">switch</span> (event.type)
<a name="l00117"></a>00117                 {
<a name="l00118"></a>00118                 <span class="keywordflow">case</span> SDL_KEYDOWN:
<a name="l00119"></a>00119                         in-&gt;key[<span class="keyword">event</span>.key.keysym.sym]=1; <span class="comment">// Met 1 quand une touche est enfoncée</span>
<a name="l00120"></a>00120                         <span class="keywordflow">break</span>;
<a name="l00121"></a>00121                 <span class="keywordflow">case</span> SDL_KEYUP:
<a name="l00122"></a>00122                         in-&gt;key[<span class="keyword">event</span>.key.keysym.sym]=0; <span class="comment">// Met 0 quand une touche est relevée</span>
<a name="l00123"></a>00123                         <span class="keywordflow">break</span>;
<a name="l00124"></a>00124                 <span class="keywordflow">default</span>:
<a name="l00125"></a>00125                         <span class="keywordflow">break</span>;
<a name="l00126"></a>00126                 }
<a name="l00127"></a>00127         }
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129 
<a name="l00130"></a>00130 
<a name="l00131"></a><a class="code" href="_sdl_jeu_8h.html#ac603fcfc9773438938b8913ea38ac0ce">00131</a> <span class="keywordtype">void</span> <a class="code" href="_sdl_jeu_8c.html#ac603fcfc9773438938b8913ea38ac0ce" title=" Brief Description  Initialise in.  ">initEvents</a>(<a class="code" href="struct_input.html">Input</a>* in)
<a name="l00132"></a>00132 {
<a name="l00133"></a>00133         memset(in,0,<span class="keyword">sizeof</span>(<a class="code" href="struct_input.html">Input</a>));
<a name="l00134"></a>00134 }
<a name="l00135"></a>00135 
<a name="l00136"></a>00136 
<a name="l00137"></a>00137 
<a name="l00138"></a><a class="code" href="_sdl_jeu_8h.html#a5e89604c62c942df8c827ac35f936fdf">00138</a> <span class="keywordtype">void</span> <a class="code" href="_sdl_jeu_8c.html#a5e89604c62c942df8c827ac35f936fdf" title=" Brief Description  Initialise le SDL.  ">sdlInit</a>(<a class="code" href="structsdl_jeu.html">sdlJeu</a> * pSj)
<a name="l00139"></a>00139 {
<a name="l00140"></a>00140     <a class="code" href="_jeu_8c.html#adea2de1f9bb9c58341d64db6e20261cc" title=" Brief Description  initialise le jeu.  ">jeuInit</a>(&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>);
<a name="l00141"></a>00141     SDL_Init(SDL_INIT_VIDEO);
<a name="l00142"></a>00142     <a class="code" href="_sdl_jeu_8c.html#a92ebd83590fab5f62f26f371b60e1b14" title=" Brief Description  Initialise les tilesets.   ">tilesetInit</a>(<span class="stringliteral">&quot;data/NiveauDépart.txt&quot;</span>, &amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>, &amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#a6e86870a6deca6724587a225b5255e2d">sTile</a>);
<a name="l00143"></a>00143     pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#af0658fc8d5710420a9e3d2704003178d">vx</a>=0;
<a name="l00144"></a>00144     <a class="code" href="_score_8c.html#aa9b64bf47785778438e880367c2ec66c" title=" Brief Description  Initialise le score.  ">scoreInit</a>(pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a53944514a19f727f5e26a8edb69a1749">Score</a>);
<a name="l00145"></a>00145         <a class="code" href="_sdl_jeu_8c.html#ac603fcfc9773438938b8913ea38ac0ce" title=" Brief Description  Initialise in.  ">initEvents</a>(&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#a7053525e65201f159ef8fe972d4a8e8f">in</a>);
<a name="l00146"></a>00146         SDL_Init(SDL_INIT_VIDEO);
<a name="l00147"></a>00147         pSj-&gt;<a class="code" href="structsdl_jeu.html#af6a1e9a15b28ef549d577605c0666f93">screen</a> = SDL_SetVideoMode(<a class="code" href="_sdl_jeu_8h.html#a6068a247ff9ece1b0a9773c58144906c">LARGEUR_FENETRE</a>,<a class="code" href="_sdl_jeu_8h.html#afd1a1e285af564b849b17498e82e1a41">HAUTEUR_FENETRE</a>,32,SDL_HWSURFACE|SDL_DOUBLEBUF);
<a name="l00148"></a>00148     pSj-&gt;<a class="code" href="structsdl_jeu.html#ac480aa6f513bc16164ff1417ef177603">perso</a>=<a class="code" href="_sprite_8c.html#a4b649c7fe373641fefdc8c50f1170c57" title=" Brief Description  Initialise un sprite.  ">InitialiserSprite</a>(pSj-&gt;<a class="code" href="structsdl_jeu.html#ac480aa6f513bc16164ff1417ef177603">perso</a>,150,150,24,30,&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>);
<a name="l00149"></a>00149         pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>.<a class="code" href="structs_terrain.html#a276723ce5e13846eaf00445cf0206b54">focusSprite</a>=<a class="code" href="_terrain_8c.html#a1ed790fb54f2f8aa6a08b2490a14a03f" title=" Brief Description Focalise la fenêtre sur le personnage.   ">FocusScrollBox</a>(&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>,pSj-&gt;<a class="code" href="structsdl_jeu.html#ac480aa6f513bc16164ff1417ef177603">perso</a>,200,150,0,0);
<a name="l00150"></a>00150 }
<a name="l00151"></a>00151 
<a name="l00152"></a>00152 
<a name="l00153"></a><a class="code" href="_sdl_jeu_8h.html#a2ef643359ceb7c52647ae6573a6e574f">00153</a> <span class="keywordtype">void</span> <a class="code" href="_sdl_jeu_8c.html#a97bab0e0a1d30cbaa850699e06dcab92" title=" Brief Description  Fait tourner le jeu sous SDL.  ">sdljeuBoucle</a>(<a class="code" href="structsdl_jeu.html">sdlJeu</a> * pSj)
<a name="l00154"></a>00154 {
<a name="l00155"></a>00155     <span class="keywordtype">int</span> jeutermine=0;
<a name="l00156"></a>00156     <span class="keywordtype">int</span> finboucle=0;
<a name="l00157"></a>00157     TTF_Init();
<a name="l00158"></a>00158     TTF_Font *Snorlax = TTF_OpenFont(<span class="stringliteral">&quot;data/LittleSnorlax.ttf&quot;</span>, 25);
<a name="l00159"></a>00159     TTF_Font *Mario = TTF_OpenFont(<span class="stringliteral">&quot;data/SuperMario256.ttf&quot;</span>, 70);
<a name="l00160"></a>00160     TTF_SetFontStyle(Mario, TTF_STYLE_NORMAL | TTF_STYLE_BOLD);
<a name="l00161"></a>00161     TTF_SetFontStyle(Snorlax,  TTF_STYLE_BOLD);
<a name="l00162"></a>00162     SDL_Color Noir = {0, 0, 0};
<a name="l00163"></a>00163     SDL_Color Rouge = {255, 0, 0};
<a name="l00164"></a>00164     <span class="keywordtype">char</span> chemin[18];
<a name="l00165"></a>00165     <a class="code" href="_terrain_8c.html#a65ce23314928441923707ec041871779">chargerTerrain</a>(&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a263d537113ffd18d7a62b8554b634801">Tersuiv</a>,<a class="code" href="_terrain_8c.html#a7c49ccfd3dd17d702e1932887b9e4a37">selectTerrain</a>(chemin),<a class="code" href="_sdl_jeu_8h.html#a6068a247ff9ece1b0a9773c58144906c">LARGEUR_FENETRE</a>,<a class="code" href="_sdl_jeu_8h.html#afd1a1e285af564b849b17498e82e1a41">HAUTEUR_FENETRE</a>);
<a name="l00166"></a>00166     <span class="keywordflow">while</span>(!(pSj-&gt;<a class="code" href="structsdl_jeu.html#a7053525e65201f159ef8fe972d4a8e8f">in</a>).key[SDLK_ESCAPE])
<a name="l00167"></a>00167         {
<a name="l00168"></a>00168             <span class="keywordflow">while</span>(finboucle==0)
<a name="l00169"></a>00169             {
<a name="l00170"></a>00170             <span class="keywordflow">while</span>(jeutermine==0)
<a name="l00171"></a>00171             {
<a name="l00172"></a>00172                 <a class="code" href="_sdl_jeu_8c.html#a907831170dedec3a0af4e4b1e178b854" title=" Brief Description  Analyse l&#39;état des events.  ">updateEvents</a>(&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#a7053525e65201f159ef8fe972d4a8e8f">in</a>);
<a name="l00173"></a>00173                 <a class="code" href="_jeu_8c.html#a352bd60c0d6e3d2d0293fde191b26b21" title=" Brief Description  Evolution du jeu.   ">jeuEvolue</a>(&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>);
<a name="l00174"></a>00174                 <span class="keywordflow">if</span> (pSj-&gt;<a class="code" href="structsdl_jeu.html#a7053525e65201f159ef8fe972d4a8e8f">in</a>.key[SDLK_UP])
<a name="l00175"></a>00175                 {
<a name="l00176"></a>00176                     <span class="keywordflow">if</span>((pSj-&gt;<a class="code" href="structsdl_jeu.html#ac480aa6f513bc16164ff1417ef177603">perso</a>-&gt;pPer-&gt;posY)&gt;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>.<a class="code" href="structs_terrain.html#add63ba136dabd9690e18e14258093f16">HAUTEUR_TILE</a>)
<a name="l00177"></a>00177                     pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a2a5b02bb12426e286475b057b44a6a12">vy</a> = -2;
<a name="l00178"></a>00178                 }
<a name="l00179"></a>00179                 <span class="keywordflow">else</span>
<a name="l00180"></a>00180                 {
<a name="l00181"></a>00181                     <span class="keywordflow">if</span>((pSj-&gt;<a class="code" href="structsdl_jeu.html#ac480aa6f513bc16164ff1417ef177603">perso</a>-&gt;pPer-&gt;posY)&lt;(pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>.<a class="code" href="structs_terrain.html#ab27a7bca0b8d1bfd8c501b0b8b4c6e69">nbtiles_hauteur_monde</a>-2)*pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>.<a class="code" href="structs_terrain.html#add63ba136dabd9690e18e14258093f16">HAUTEUR_TILE</a>)
<a name="l00182"></a>00182                         pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a2a5b02bb12426e286475b057b44a6a12">vy</a> = 2;
<a name="l00183"></a>00183                 }
<a name="l00184"></a>00184                 <a class="code" href="_sprite_8c.html#aac6a72bc14350b6bd51616dba329fe1d" title=" Brief Description  Test si les déplacements sont possibles.  ">DeplaceSprite</a>(pSj-&gt;<a class="code" href="structsdl_jeu.html#ac480aa6f513bc16164ff1417ef177603">perso</a>,pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#af0658fc8d5710420a9e3d2704003178d">vx</a>,pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a2a5b02bb12426e286475b057b44a6a12">vy</a>);
<a name="l00185"></a>00185                 <a class="code" href="_sdl_jeu_8c.html#a79155188b3432437d7b7e8853074a60e" title=" Brief Description  Affiche la carte.   ">AfficherMapSDL</a>(&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>,pSj-&gt;<a class="code" href="structsdl_jeu.html#af6a1e9a15b28ef549d577605c0666f93">screen</a>,pSj-&gt;<a class="code" href="structsdl_jeu.html#ac480aa6f513bc16164ff1417ef177603">perso</a>,&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#a6e86870a6deca6724587a225b5255e2d">sTile</a>);
<a name="l00186"></a>00186                 <a class="code" href="_sdl_jeu_8c.html#ace46279dca20b51cfe4dc815c0bf28f4" title=" Brief Description  Affiche un sprite.  ">AfficherSprite</a>(pSj-&gt;<a class="code" href="structsdl_jeu.html#ac480aa6f513bc16164ff1417ef177603">perso</a>,pSj-&gt;<a class="code" href="structsdl_jeu.html#af6a1e9a15b28ef549d577605c0666f93">screen</a>);
<a name="l00187"></a>00187                 <a class="code" href="_sdl_jeu_8c.html#a17f751f0ff69b052d47dde9c64a64dca" title=" Brief Description  Affiche le score.  ">AfficherScoreSDL</a>(pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>.<a class="code" href="structs_terrain.html#a5692b40e1e9677764b6da00a4c2c24e9">xscroll</a>,pSj-&gt;<a class="code" href="structsdl_jeu.html#af6a1e9a15b28ef549d577605c0666f93">screen</a>,Snorlax,Noir);
<a name="l00188"></a>00188                 <span class="keywordflow">if</span>(pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>.<a class="code" href="structs_terrain.html#a5692b40e1e9677764b6da00a4c2c24e9">xscroll</a>%(200)==0)
<a name="l00189"></a>00189                 {
<a name="l00190"></a>00190                     <a class="code" href="_terrain_8c.html#ae33e1396c7355287a37411d53fdf0394" title=" Brief Description  Charge la carte.   ">CopieProchCarte</a>(&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>, &amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a263d537113ffd18d7a62b8554b634801">Tersuiv</a>);
<a name="l00191"></a>00191                     <span class="keywordflow">if</span>(pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>.<a class="code" href="structs_terrain.html#a5692b40e1e9677764b6da00a4c2c24e9">xscroll</a>%(1000)==0)
<a name="l00192"></a>00192                     {
<a name="l00193"></a>00193                         <a class="code" href="_terrain_8c.html#a65ce23314928441923707ec041871779">chargerTerrain</a>(&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a263d537113ffd18d7a62b8554b634801">Tersuiv</a>,<a class="code" href="_terrain_8c.html#a7c49ccfd3dd17d702e1932887b9e4a37">selectTerrain</a>(chemin),<a class="code" href="_sdl_jeu_8h.html#a6068a247ff9ece1b0a9773c58144906c">LARGEUR_FENETRE</a>,<a class="code" href="_sdl_jeu_8h.html#afd1a1e285af564b849b17498e82e1a41">HAUTEUR_FENETRE</a>);
<a name="l00194"></a>00194                     }
<a name="l00195"></a>00195                 }
<a name="l00196"></a>00196                 SDL_Flip(pSj-&gt;<a class="code" href="structsdl_jeu.html#af6a1e9a15b28ef549d577605c0666f93">screen</a>);
<a name="l00197"></a>00197                 SDL_Delay(5);
<a name="l00198"></a>00198                 jeutermine=<a class="code" href="_sprite_8c.html#a74d0672b51f6223f75d4327e049d4b17" title=" Brief Description  Test si le personnage est mort(fin de partie).  ">persMort</a>(pSj-&gt;<a class="code" href="structsdl_jeu.html#ac480aa6f513bc16164ff1417ef177603">perso</a>, pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#af0658fc8d5710420a9e3d2704003178d">vx</a>, pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a2a5b02bb12426e286475b057b44a6a12">vy</a>);
<a name="l00199"></a>00199             }
<a name="l00200"></a>00200             <a class="code" href="_terrain_8c.html#a942cc755e3b7ac930ae732b7be92c648" title=" Brief Description  Libère la mémoire allouée .  ">libereTerrain</a>(&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a4df9d34c4af649dd172c2c7f9c1e8ffd">Ter</a>);
<a name="l00201"></a>00201             <a class="code" href="_terrain_8c.html#a942cc755e3b7ac930ae732b7be92c648" title=" Brief Description  Libère la mémoire allouée .  ">libereTerrain</a>(&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a263d537113ffd18d7a62b8554b634801">Tersuiv</a>);
<a name="l00202"></a>00202             SDL_Surface * finjeu;
<a name="l00203"></a>00203             <a class="code" href="structs_terrain.html">Terrain</a> cartefin;
<a name="l00204"></a>00204             finjeu = SDL_SetVideoMode(<a class="code" href="_sdl_jeu_8h.html#a6068a247ff9ece1b0a9773c58144906c">LARGEUR_FENETRE</a>/2,<a class="code" href="_sdl_jeu_8h.html#afd1a1e285af564b849b17498e82e1a41">HAUTEUR_FENETRE</a>,32,SDL_HWSURFACE|SDL_DOUBLEBUF);
<a name="l00205"></a>00205             <a class="code" href="_terrain_8c.html#a65ce23314928441923707ec041871779">chargerTerrain</a>(&amp;cartefin,<span class="stringliteral">&quot;data/NiveauFin.txt&quot;</span>,<a class="code" href="_sdl_jeu_8h.html#a6068a247ff9ece1b0a9773c58144906c">LARGEUR_FENETRE</a>,<a class="code" href="_sdl_jeu_8h.html#afd1a1e285af564b849b17498e82e1a41">HAUTEUR_FENETRE</a>);
<a name="l00206"></a>00206             <a class="code" href="_sdl_jeu_8c.html#a92ebd83590fab5f62f26f371b60e1b14" title=" Brief Description  Initialise les tilesets.   ">tilesetInit</a>(<span class="stringliteral">&quot;data/NiveauFin.txt&quot;</span>,&amp;cartefin, &amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#a6e86870a6deca6724587a225b5255e2d">sTile</a>);
<a name="l00207"></a>00207             <a class="code" href="_sdl_jeu_8c.html#a79155188b3432437d7b7e8853074a60e" title=" Brief Description  Affiche la carte.   ">AfficherMapSDL</a>(&amp;cartefin,finjeu,pSj-&gt;<a class="code" href="structsdl_jeu.html#ac480aa6f513bc16164ff1417ef177603">perso</a>,&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#a6e86870a6deca6724587a225b5255e2d">sTile</a>);
<a name="l00208"></a>00208             <a class="code" href="_sdl_jeu_8c.html#a6f766d4620f74ae8bcdac5f887092695" title=" Brief Description  Affiche le menu de fin de partie.   ">MenuFinJeu</a>(finjeu,Mario,Snorlax,Noir,Rouge);
<a name="l00209"></a>00209             SDL_Delay(5);
<a name="l00210"></a>00210             finboucle=1;
<a name="l00211"></a>00211             }
<a name="l00212"></a>00212         <a class="code" href="_sdl_jeu_8c.html#a907831170dedec3a0af4e4b1e178b854" title=" Brief Description  Analyse l&#39;état des events.  ">updateEvents</a>(&amp;pSj-&gt;<a class="code" href="structsdl_jeu.html#a7053525e65201f159ef8fe972d4a8e8f">in</a>);
<a name="l00213"></a>00213         }
<a name="l00214"></a>00214     TTF_CloseFont(Snorlax);
<a name="l00215"></a>00215 }
<a name="l00216"></a>00216 
<a name="l00217"></a><a class="code" href="_sdl_jeu_8h.html#a02a9d84a4c2120bbb087f7ce7d3550cb">00217</a> <span class="keywordtype">void</span> <a class="code" href="_sdl_jeu_8c.html#a17f751f0ff69b052d47dde9c64a64dca" title=" Brief Description  Affiche le score.  ">AfficherScoreSDL</a>(<span class="keywordtype">int</span> core,SDL_Surface* screen,TTF_Font *Snorlax,SDL_Color Couleur)
<a name="l00218"></a>00218 {
<a name="l00219"></a>00219 
<a name="l00220"></a>00220     <span class="keywordtype">char</span>  score2[50] ;
<a name="l00221"></a>00221     sprintf(score2, <span class="stringliteral">&quot;Score : %d&quot;</span>,core);
<a name="l00222"></a>00222     SDL_Surface *<a class="code" href="_menu_8c.html#a3a9aeffc30e95b3d937df7f3b58df759" title=" Brief Description  Affiche les Meilleurs scores.  ">score</a>;
<a name="l00223"></a>00223     SDL_Rect  posScore;
<a name="l00224"></a>00224     score = TTF_RenderText_Blended(Snorlax,score2,Couleur);
<a name="l00225"></a>00225     posScore.x = 980;
<a name="l00226"></a>00226     posScore.y = 10;
<a name="l00227"></a>00227     SDL_BlitSurface(score, NULL,screen, &amp;posScore);
<a name="l00228"></a>00228 
<a name="l00229"></a>00229 }
<a name="l00230"></a>00230 
<a name="l00231"></a>00231 
<a name="l00232"></a><a class="code" href="_sdl_jeu_8h.html#a1d05d7d58fdff72e97f5b8e70b10299d">00232</a> <span class="keywordtype">void</span> <a class="code" href="_sdl_jeu_8c.html#a1d05d7d58fdff72e97f5b8e70b10299d" title=" Brief Description  Libère SDL.  ">sdlLibere</a>( <a class="code" href="structsdl_jeu.html">sdlJeu</a> *pSj)
<a name="l00233"></a>00233 {
<a name="l00234"></a>00234     <a class="code" href="_score_8c.html#a0a8a79edcaa87cb62fca2ea9fa0ce6de" title=" Brief Description  Vérifie le score.  ">verifScore</a>(pSj-&gt;<a class="code" href="structsdl_jeu.html#af8ecd261d2be49f4f871b798faf0bf3a">Jeu</a>.<a class="code" href="struct_jeu.html#a53944514a19f727f5e26a8edb69a1749">Score</a>,<span class="stringliteral">&quot;data/Score.txt&quot;</span>);
<a name="l00235"></a>00235         SDL_FreeSurface(pSj-&gt;<a class="code" href="structsdl_jeu.html#af6a1e9a15b28ef549d577605c0666f93">screen</a>);
<a name="l00236"></a>00236         SDL_Quit();
<a name="l00237"></a>00237 }
<a name="l00238"></a>00238 
<a name="l00239"></a><a class="code" href="_sdl_jeu_8h.html#a6f766d4620f74ae8bcdac5f887092695">00239</a> <span class="keywordtype">void</span> <a class="code" href="_sdl_jeu_8c.html#a6f766d4620f74ae8bcdac5f887092695" title=" Brief Description  Affiche le menu de fin de partie.   ">MenuFinJeu</a>(SDL_Surface *ecran, TTF_Font *Mario,TTF_Font *Snorlax,
<a name="l00240"></a>00240                   SDL_Color Noir, SDL_Color Rouge)
<a name="l00241"></a>00241 {
<a name="l00242"></a>00242 
<a name="l00243"></a>00243     SDL_Surface *select = NULL, *titre = NULL, *caption = NULL;
<a name="l00244"></a>00244     SDL_Rect  posTitre, posCaption, posSelect;
<a name="l00245"></a>00245     SDL_Event instructions;
<a name="l00246"></a>00246     <span class="keywordtype">int</span> continuer = 1;
<a name="l00247"></a>00247     titre = TTF_RenderText_Blended(Mario, <span class="stringliteral">&quot;Fin de partie&quot;</span>, Rouge);
<a name="l00248"></a>00248     posTitre.x = ecran-&gt;w / 2 - titre-&gt;w / 2;
<a name="l00249"></a>00249     posTitre.y = 10;
<a name="l00250"></a>00250     select = TTF_RenderText_Blended(Snorlax, <span class="stringliteral">&quot;[ECH] Quitter&quot;</span>, Noir);
<a name="l00251"></a>00251     posSelect.x = ecran-&gt;w / 2 - select-&gt;w / 2;
<a name="l00252"></a>00252     posSelect.y = 300;
<a name="l00253"></a>00253     caption = TTF_RenderText_Blended(Snorlax, <span class="stringliteral">&quot;[M] Menu Principal&quot;</span>, Noir);
<a name="l00254"></a>00254     posCaption.x = ecran-&gt;w / 2 - caption-&gt;w / 2;
<a name="l00255"></a>00255     posCaption.y = 350;
<a name="l00256"></a>00256     SDL_BlitSurface(titre, NULL, ecran, &amp;posTitre);
<a name="l00257"></a>00257     SDL_BlitSurface(select, NULL, ecran, &amp;posSelect);
<a name="l00258"></a>00258     SDL_BlitSurface(caption, NULL, ecran, &amp;posCaption);
<a name="l00259"></a>00259     SDL_Flip(ecran);
<a name="l00260"></a>00260     <span class="keywordflow">while</span> (continuer)
<a name="l00261"></a>00261     {
<a name="l00262"></a>00262         SDL_WaitEvent(&amp;instructions);
<a name="l00263"></a>00263         <span class="keywordflow">switch</span>(instructions.type)
<a name="l00264"></a>00264         {
<a name="l00265"></a>00265             <span class="keywordflow">case</span> SDL_QUIT:
<a name="l00266"></a>00266             continuer = 0;
<a name="l00267"></a>00267             exit(EXIT_SUCCESS);
<a name="l00268"></a>00268             <span class="keywordflow">break</span>;
<a name="l00269"></a>00269             <span class="keywordflow">case</span> SDL_KEYDOWN:
<a name="l00270"></a>00270             <span class="keywordflow">switch</span>(instructions.key.keysym.sym)
<a name="l00271"></a>00271             {
<a name="l00272"></a>00272                 <span class="keywordflow">case</span> SDLK_m:
<a name="l00273"></a>00273                 <span class="keywordflow">default</span> :
<a name="l00274"></a>00274                 <a class="code" href="main_8c.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a>(1, <span class="stringliteral">&quot;Menu Principal&quot;</span>);
<a name="l00275"></a>00275                 <span class="keywordflow">break</span>;
<a name="l00276"></a>00276                 <span class="keywordflow">case</span> SDLK_ESCAPE:
<a name="l00277"></a>00277                 continuer = 0;
<a name="l00278"></a>00278                 exit(EXIT_SUCCESS);
<a name="l00279"></a>00279                 <span class="keywordflow">break</span>;
<a name="l00280"></a>00280              }
<a name="l00281"></a>00281         }
<a name="l00282"></a>00282     }
<a name="l00283"></a>00283     SDL_FreeSurface(titre);
<a name="l00284"></a>00284     SDL_FreeSurface(select);
<a name="l00285"></a>00285 
<a name="l00286"></a>00286 }
<a name="l00287"></a>00287 
<a name="l00288"></a>00288 
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_sdl_jeu_8c.html">SdlJeu.c</a>      </li>

    <li class="footer">Généré le Lundi Décembre 17 2012 01:09:40 pour Projet Jetpack par
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
